package com.onpositive.inferencer;

import com.onpositive.semantic.model.api.property.IProperty;

public abstract class PropertyDependencyTheory extends AbstractTheory{

	protected IProperty sourceProperty;

	public PropertyDependencyTheory(IProperty about,IProperty sourceProperty) {
		super(about);
		this.sourceProperty=sourceProperty;
	}

	@Override
	protected void adjustStats(Object sample) {
		adjust(sample,sourceProperty);
	}

	protected abstract void adjust(Object sample, IProperty srcProp);

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result
				+ ((sourceProperty == null) ? 0 : sourceProperty.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		PropertyDependencyTheory other = (PropertyDependencyTheory) obj;
		if (sourceProperty == null) {
			if (other.sourceProperty != null)
				return false;
		} else if (!sourceProperty.equals(other.sourceProperty))
			return false;
		return true;
	}
	
	public String getPropertyId()
	{
		return sourceProperty.getId() ;
	}

}
